home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK2.toast / Development Kits (Disc 2) / ScriptX / Draggable ScriptX Folders / utils / DTK / Examples / Custom Classes / Scene.cls < prev    next >
Encoding:
Text File  |  1995-11-30  |  2.6 KB  |  110 lines  |  [TEXT/ttxt]

  1. format debug "--  Compiling Scene Class . . .\n" undefined undefined
  2.  
  3. Class Scene(TwoDSpace)
  4. instance variables
  5.     sceneMasterClock
  6.     currentDropSpot
  7.     myControllers
  8.     myStage
  9.     name
  10.     helpVideo
  11.     sceneAudio
  12.     loopAudio
  13.     players
  14.     BOM
  15.     Portals
  16.     loopCB
  17. End --Scene
  18.  
  19. method afterInit self {class Scene} #rest args #key lingo:->
  20. (
  21.     local myControllers := self.myControllers
  22.     myControllers := new array
  23.     append myControllers (new DragController space:self wholespace:true)
  24.     append myControllers (new Movement space:self wholespace:true)
  25.     append myControllers (new SmartBounce space:self wholespace:true)
  26.     append myControllers (new ActuatorController space:self wholespace:true)
  27.     self.myControllers := myControllers
  28.     self.sceneAudio := undefined
  29.     self.BOM := new Array
  30.     local portals := #(@north:undefined,@south:undefined,@east:undefined,@west:undefined)
  31.     
  32.     local thisPortal := findSXKey(lingo, "North")
  33.     if thisPortal <> undefined do setOne portals @North thisPortal
  34.     
  35.     thisPortal := findSXKey(lingo, "South")
  36.     if thisPortal <> undefined do setOne portals @South thisPortal
  37.     
  38.     thisPortal := findSXKey(lingo, "East")
  39.     if thisPortal <> undefined do setOne portals @East thisPortal
  40.     
  41.     thisPortal := findSXKey(lingo, "West")
  42.     if thisPortal <> undefined do setOne portals @West thisPortal
  43.     
  44.     self.loopAudio := (findSXKey(lingo, "soundLooped") = "yes")
  45.     self.portals := portals
  46.     self.players := #()
  47.     return self
  48. )
  49.  
  50. method unhook self {Class Scene} ->
  51. (
  52.     for ctrl in self.myControllers do (
  53.         if ctrl.enabled = true do (
  54.             ctrl.enabled := false
  55.         )
  56.     )
  57.     for element in self do (
  58.         if (canObjectDo element unhook) do (
  59.             unhook element
  60.         )
  61.     )
  62.     local loop := self.loopCB
  63.     if loop <> undefined do (
  64.         cancel loop
  65.         self.loopCB := undefined
  66.     )
  67.     for plyr in self.players do stop plyr
  68. )
  69.  
  70. method hook self {Class Scene} ->
  71. (
  72.     for ctrl in self.myControllers do (
  73.         if ctrl.enabled = false do (
  74.             ctrl.enabled := true
  75.         )
  76.     )
  77.     for element in self do (
  78.         if (canObjectDo element hook) do (
  79. --            format debug "hooking: %*\n" element @unadorned
  80.             hook element
  81.         )
  82.     )
  83. )
  84.  
  85. method showHelp self {Class Scene} ->
  86. (
  87.     local orb := self[1]
  88.     if orb.size = 1 then (
  89.         local myHelp := self.helpVideo
  90.         if (not (isAKindOf orb SlingShotOrb)) or myHelp = undefined do
  91.             return empty
  92.         stop myHelp
  93.         gotoBegin myHelp
  94.         playprepare myHelp 1
  95.         if orb[1] <> myHelp do
  96.             prepend orb myHelp
  97.         play myHelp
  98.     ) else (
  99.         pop orb
  100.     )
  101. )
  102. method setHelp self {Class Scene} helpVid->
  103. (
  104.     if helpVid <> undefined do (
  105.         helpVid[1].invisibleColor := new rgbColor red:51 green:51 blue:255
  106.         self.helpVideo := helpVid
  107.     )
  108. )
  109. #(Scene,#("portals","name","myControllers","sceneAudio","players","loopAudio"),#("hook","unhook","showHelp","setHelp"))
  110.